import java.util.Scanner;

public class MagicSquare {
    public static void main(String[] args) {
        Scanner input=new Scanner(System.in);
        int number=input.nextInt();
        int[][] magicSquare=new int[number][number];

        if(number%2==1){
            OddMagic(number,magicSquare);
            print(number,magicSquare);
        }

        if(number<3) System.out.println("impossible");
        else if(number%2==1) {OddMagic(number,magicSquare); if(Check(number,magicSquare))
            print(number,magicSquare);}                    //输出奇数阶幻方
        else if((number%4==0)) {DoubleEvenMagic(number,magicSquare); if(Check(number,magicSquare)) print(number,magicSquare);}     //输出双偶数阶幻方
        else {singleEvenMagic(number,magicSquare);
            if(Check(number,magicSquare))
                print(number,magicSquare);
        }

    }


    static void OddMagic(int n,int[][] magicSquare) {
        int x=0,y,m;
        y=n/2;

        for(m=1;m<=n*n;m++)
        {
            magicSquare[x][y]=m;
            if(m%n!=0)
            {
                //后面的每一个数存放的行比前一个数的行数减1，列数加1
                x--;
                y++;
                //如果超界要从另一面进来
                if(x<0)
                    x+=n;
                if(y==n)
                    y=n-y;
            }else
            {
                //如果右上角已经有数字了，则后一个数字在当前数字下
                x++;
                if(x==n)
                    x=x-n;
            }
        }

    }


    static  void print(int number,int[][] magicSquare){

        for(int i=0; i<number; i++)
            for(int j=0; j<number; j++)
                if(j==number-1) System.out.println(magicSquare[i][j]+"\n");
                else System.out.print(magicSquare[i][j]+" ");
    }

    static  void DoubleEvenMagic(int n,int[][] magicSquare)                  //双偶数阶幻方
    {
        //幻方清零
        for(int i=1, x=0, y=0; i<=n*n; i++)      //依次按顺序赋初值
        {
            magicSquare[x][y]=i;
            y++;
            if(y>n-1) {x++; y-=n;}
        }
        for(int i=0; i<n; i++)                   //将幻方分解成m*m个4阶幻方，并将每个4阶幻方的对角线元素换成其互补数
            for(int j=0; j<n; j++)
                if(i%4==0 && j%4==0)             //左对角线
                    for(int k=0; k<4; k++)
                        magicSquare[i+k][j+k]=(n*n+1)-magicSquare[i+k][j+k];
                else if(i%4==3 &&j%4==0)         //右对角线
                    for(int k=0; k<4; k++)
                        magicSquare[i-k][j+k]=(n*n+1)-magicSquare[i-k][j+k];
    }

    static void singleEvenMagic(int n,int[][] magicSquare) {
        int k, i, j, p, t;
        k = n / 2;
        OddMagic(k, magicSquare);
	/*
		先赋初值
		上左子阵最小（i），下右子阵次小（i+v），下左子阵最大（i+3v），上右子阵次大（i+2v)
		即4个子方阵对应元素相差v，其中v=n*n/4
	*/
        for (i = 0; i < k; i++)
            for (j = 0; j < k; j++) {
                magicSquare[i][j + k] = magicSquare[i][j] + 2 * k * k;
                magicSquare[i + k][j] = magicSquare[i][j] + 3 * k * k;
                magicSquare[i + k][j + k] = magicSquare[i][j] + k * k;
            }
        t = (n - 2) / 4;
        for (i = 0; i < k; i++)
            for (j = 0; j < k; j++) {
                if ((j < t) && (i < t)) {
                    p = magicSquare[i][j];
                    magicSquare[i][j] = magicSquare[i + k][j];
                    magicSquare[i + k][j] = p;
                }
                if ((j < t) && (i > k - t - 1)) {
                    p = magicSquare[i][j];
                    magicSquare[i][j] = magicSquare[i + k][j];
                    magicSquare[i + k][j] = p;
                }
                if ((i >= t && i <= k - t - 1) && (j >= t && j < t * 2)) {
                    p = magicSquare[i][j];
                    magicSquare[i][j] = magicSquare[i + k][j];
                    magicSquare[i + k][j] = p;
                }
                if (j > 1 && j <= t) {
                    p = magicSquare[i][j + k];
                    magicSquare[i][j + k] = magicSquare[i + k][j + k];
                    magicSquare[i + k][j + k] = p;
                }
            }
    }

    static boolean Check(int n,int[][] magicSquare)
    {
        int cnt=n*(n*n+1)/2;                                //每行每列以及对角线之和
        for(int i=0; i<n; i++)
        {
            int sum_row=0,sum_line=0;
            for(int j=0; j<n; j++)
            {
                sum_row+=magicSquare[i][j];                       //检查各行
                sum_line+=magicSquare[j][i];                      //检查各列
            }
            if(sum_row!=cnt || sum_line!=cnt) return false;
        }
        int sum_left=0,sum_right=0;
        for(int i=0; i<n; i++)
        {
            sum_left+=magicSquare[i][i];                              //检查左对角线
            sum_right+=magicSquare[n-i-1][i];                         //检查右对角线
        }
        if(sum_left!=cnt || sum_right!=cnt) {
            return false;
        }
        return true;
    }
}
